package cn.kgc.ssm.controller;

import cn.kgc.ssm.entity.Message;
import cn.kgc.ssm.service.MessageService;
import cn.kgc.ssm.utils.ResponseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @author 课工场
 * @date 2024/3/8
 * @description
 */
@RestController
@RequestMapping("message")
public class MessageController {

    @Resource
    private MessageService messageService;

    //发布留言
    @PostMapping("publish")
    public ResponseResult publishMessage(Message message, HttpSession session){
        return messageService.publishMessage(message,session);
    }

    //  留言分页查询
    @GetMapping("page")
    public ResponseResult messagePage(Integer page,Integer limit,String memberName){
        return messageService.messagePage(page,limit,memberName);
    }

    // 删除留言
    @GetMapping("delete")
    public ResponseResult deleteMessage(Integer[] ids){
        return messageService.deleteMessage(ids);
    }

    // 编辑留言状态
    @PostMapping("edit")
    public ResponseResult editMessageStatus(Integer id){
        return messageService.editMessageStatus(id);
    }

}
